{extend name="layout/main" /}

{block name="header"}

{/block}

{block name="content"}
<section class="panel">
    <header class="panel-heading">
        <h4>文章列表</h4>
    </header>
    <div class="panel-body" style="padding-bottom: 50px">
        <form class="form-horizontal" action="{:url('article/index')}">
            <div class="form-group">
                <div class="col-xs-3">
                    <select name="type" class="form-control">
                        <option value="0">全部分类</option>
                        {foreach $cate as $key=>$item}
                        <option {if $Request.get.type == $key}selected{/if} value="{$key}">{$item}</option>
                        {/foreach}
                    </select>
                </div>
                <button type="submit" class="btn btn-color">搜索</button>
                <a type="button" href="{:url('/admin/article/create')}" class="btn btn-info">添加文章</a>
            </div>
        </form>
        <table class="table table-bordered table-striped no-margin">
            <thead>
            <tr>
                <th class="text-center">ID</th>
                <th class="text-center">标题</th>
                <th class="text-center">类型</th>
                <th class="text-center">内容</th>
                <th class="text-center">状态</th>
                <th class="text-center">创建时间</th>
                <th class="text-center">操作</th>
            </tr>
            </thead>
            <tbody>
            {if !empty($list)}
            {foreach $list as $entity}
            <tr>
                <td class="text-center">{$entity->article_id}</td>
                <td class="text-center">{$entity->title}</td>
                <td class="text-center">{$entity->getCate()}</td>
                <td class="text-center">
                    <a onclick="showContent(this)" data-content="{$entity->content}" class="btn btn-xs btn-primary">查看</a>
                </td>
                <td class="text-center">
                    {if $entity->isShow()}
                        <a class="btn btn-xs btn-primary">已发布</a>
                    {else /}
                        <a class="btn btn-xs btn-warning">未发布</a>
                    {/if}

                </td>
                <td class="text-center">{$entity->getCreateTime()}</td>
                <td class="text-center">
                    <a href="{:url('article/edit',['id'=>$entity->article_id])}" class="btn btn-xs btn-info">编辑</a>
                    {if $entity->article_id != 3 && $entity->article_id != 5}
                    <a data-url="{:url('article/delete',['id'=>$entity->article_id])}" onclick="main.ajaxDelete(this)"
                       data-msg="确定要删除该公告吗？" class="btn btn-xs btn-danger">删除</a>
                    {/if}
                </td>
            </tr>
            {/foreach}
            {else /}
            <tr class="text-center">
                <td colspan="5">暂无数据</td>
            </tr>
            {/if}
            </tbody>
        </table>
        <div class="page">
            {:htmlspecialchars_decode($list->render())}
        </div>
    </div>
</section>
{/block}


{block name="footer"}
    <script>
        function showContent(e){
            $.dialog({
                title: '文章内容',
                content: $(e).attr('data-content')
            });
        }
    </script>
{/block}